'use strict';
const dayjs = require("dayjs");
module.exports = app => {
    const { STRING, INTEGER, TEXT, DATE } = app.Sequelize;
    return app.model.define(
      'Contact',
      {
          id: {type: INTEGER, primaryKey: true, autoIncrement: true},
          nickname: STRING,
          subject: STRING,
          email: STRING,
          phone: STRING,
          content: TEXT,
          status: INTEGER,
          create_time: {
              type: DATE,
              get() {
                  return dayjs(this.getDataValue('create_time')).format('YYYY-MM-DD HH:mm:ss');
              }
          },
      },
      {
          tableName: 'contact',
          timestamps: true, // 启用时间戳(createdAt, updatedAt)
          updatedAt: 'updated_time', // 不想要 updatedAt
          createdAt: 'create_time', // 想要  createdAt 但是希望名称叫做 created_at
      }
  )
};
/**
 * 建表语句
 */

